const express = require('express')
const router = express.Router()

// 首页路由
router.get('/', (req, res) => {
  res.send('Hello Express on Tencent Cloud Serverless!')
})

// 时间接口
router.get('/time', (req, res) => {
  let time = new Date()
  res.send(time.toString())
})

// 用户信息接口
router.get('/user', (req, res) => {
  res.json({
    name: 'Express Demo',
    email: 'example@example.com',
    site: 'https://cloud.tencent.com/'
  })
})

// 健康检查接口
router.get('/health', (req, res) => {
  const healthInfo = {
    status: 'healthy',
    timestamp: new Date().toISOString(),
    uptime: process.uptime(),
    memory: process.memoryUsage(),
    version: process.version
  }
  res.json(healthInfo)
})

module.exports = router